﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class CulturalTravel
    {
        public CulturalTravel()
        {
            int totalTime = GetConsole.GetInt();
            int positionCount = GetConsole.GetInt();
            Dictionary<int, int> positionList = new Dictionary<int,int>();
            for (int i = 0; i < positionCount; i++)
            {
                int position = GetConsole.GetInt();
                positionList.Add(Math.Abs(position), position);
            }
            //절대값으로 정렬
            List<int> lengthList = positionList.Keys.ToList();
            lengthList.Sort();
            
            int usedTime = 0;
            int beforePosition = 0;
            int travelCount = 0;
            for (int i = 0; i < lengthList.Count;i++ )
            {
                int addTime = Math.Abs((beforePosition - positionList[lengthList[i]]));
                usedTime += addTime;
                if (usedTime > totalTime)
                {
                    break;
                }
                else
                {
                    travelCount++;
                    beforePosition = positionList[lengthList[i]];
                }
            }
            Console.WriteLine(travelCount);
        }
    }
}
